package processbuilder;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.function.Consumer;
import org.apache.commons.io.IOUtils;

public class ProcessBuilderTest {

    public static void main(String[] args) throws IOException, InterruptedException {

        Consumer<InputStream> inputStreamConsumer = (input) -> {
            try {
                System.out.println(IOUtils.toString(input, "UTF-8"));
            } catch (IOException e) {
                e.printStackTrace();
            }
        };

        ProcessBuilder processBuilder = new ProcessBuilder("ifconfig");
        processBuilder.redirectErrorStream(true);
        Process process = processBuilder.start();

        inputStreamConsumer.accept(process.getInputStream());
        process.waitFor();
    }
}
